package com.zhuhao.utils.httpclient;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.Method;
import org.junit.Test;

import java.util.HashMap;

/**
 * hutool工具httpclient
 * @Author haozhu7
 * @Date 2025/5/20 14:43
 **/
public class HutoolHttpUtil {


    public static final String url = "http://cbd.brain.com/service/biims-clctdash/api/more/than/site/info";
    public static final String token = "Bearer f46501f8-8b1a-4c90-a745-e4fafce5d0f4";

    @Test
    public void postTest() {

        HashMap<String, String> headMap = new HashMap<>();
        headMap.put("Authorization", token);

        HttpRequest httpRequest = HttpRequest.post(url)
                .addHeaders(headMap)
                .setMethod(Method.POST)
                .contentType("application/json")
                .body("{\n" +
                        "  \"siteId\": \"CNU\",\n" +
                        "  \"size\": 15,\n" +
                        "  \"page\": 1\n" +
                        "}");

        HttpResponse execute = httpRequest.execute();
        System.out.println(execute.body());

    }
}
